/*
 * Middleware
 * Copyright (C) 2010/11
 * Riccardo Pulvirenti, Giuseppe Ravidà, Andrea Tino
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses
 */

/*!
 * File: activity.hpp
 */

#ifndef _ACTIVITY_HPP_
#define _ACTIVITY_HPP_

#include <iostream>
#include <string>

#include "workflow.hpp"
#include "worker_network.hpp"

//-----------------------------------------------------------------------------
// Class definitions
namespace middleware {
/*! \class Activity
 * \brief Represents an activity consisting in a workflow and in a
 * workernetwork to connect a workflow to its minimum working set.
 *
 * More detailed
 */
class Activity {
public:
	typedef Workflow::TaskCollectionIterator TaskCollectionIterator;
	typedef Workflow::TaskCollectionConstIterator TaskCollectionConstIterator;
	typedef WorkerNetwork::AddressCollectionIterator AddressCollectionIterator;
	typedef WorkerNetwork::AddressCollectionConstIterator
			AddressCollectionConstIterator;
	/*!
	 * Constructs an empty activity.
	 */
	Activity();
	/*!
	 * Copy constructor.
	 */
	Activity(const Activity& activity);
	/*!
	 * Destrucotr.
	 */
	~Activity();
	/*!
	 * Copies the passed workflow, in the underlaying, corresponding,
	 * collection.
	 */
	void set_workflow(const Workflow& workflow) {
		this->_workflow = workflow; /* Calling copy constructor */
	}
	/*!
	 * Copies the passed workflow, in the underlaying, corresponding,
	 * collection.
	 */
	void set_sbn(const WorkerNetwork& wn) {
		this->_sbn = wn;
	}
	/*!
	 * Workflow iterator starting from top.
	 */
	TaskCollectionIterator begin_workflow() {
		return this->_workflow.begin();
	}
	/*!
	 * Workflow const iterator starting from top.
	 */
	TaskCollectionConstIterator begin_workflow() const {
		return this->_workflow.begin();
	}
	/*!
	 * WorkerNetwork iterator starting from top.
	 */
	AddressCollectionIterator begin_sbn() {
		return this->_sbn.begin();
	}
	/*!
	 * WorkerNetwork const iterator starting from top.
	 */
	AddressCollectionConstIterator begin_sbn() const {
		return this->_sbn.begin();
	}
	/*!
	 * Workflow iterator starting from bottom.
	 */
	TaskCollectionIterator end_workflow() {
		return this->_workflow.end();
	}
	/*!
	 * Workflow const iterator starting from bottom.
	 */
	TaskCollectionConstIterator end_workflow() const {
		return this->_workflow.end();
	}
	/*!
	 * WorkerNetwork iterator starting from end.
	 */
	AddressCollectionIterator end_sbn() {
		return this->_sbn.end();
	}
	/*!
	 * WorkerNetwork const iterator starting from top.
	 */
	AddressCollectionConstIterator end_sbn() const {
		return this->_sbn.end();
	}
private:
	/*!
	 * Workflow of activity.
	 */
	Workflow _workflow;
	/*!
	 * WorkerNetwork of activity
	 */
	WorkerNetwork _sbn;
}; /* Activity */
} /* middleware */

#endif
